package com.atguigu.lease.common.config;

import com.atguigu.lease.common.converter.BaseEnumConverterFactory;
import com.atguigu.lease.common.converter.StringToItemTypeConverter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
//WebMvcConfigurer：springmvc的 配置父接口，可以实现配置 跨域、注册转换器....方法
@Configuration
public class LeaseWebMvcConfig implements WebMvcConfigurer {
//    @Autowired
//    StringToItemTypeConverter stringToItemTypeConverter;

//    @Override
//    public void addFormatters(FormatterRegistry registry) {
//        //将消息转换器注册给springmvc，它才会转换ItemType类型的参数
//        registry.addConverter(stringToItemTypeConverter);
//    }
    @Autowired
    BaseEnumConverterFactory baseEnumConverterFactory;

    @Override
    public void addFormatters(FormatterRegistry registry) {
        registry.addConverterFactory(baseEnumConverterFactory);
    }
}
